package com.hexb.smh.mapper;

import com.hexb.smh.entity.Commission;
import com.hexb.smh.entity.view.CommissionAmount;
import com.hexb.smh.entity.view.CommissionDiscountRate;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author : hexb
 */
@Mapper
@Repository
public interface CommissionMapper {

    int saveOrUpdate(Commission commission);

    void insertBatch(List<Commission> commissions);

    @Update("update commission set amount=#{amount},updateBy=#{updateBy} where id=#{id}")
    int update(Commission commission);

    List<CommissionDiscountRate> getDiscountRate(@Param("brandId") Integer brandId);

    List<CommissionAmount> getAmount(@Param("brandId") Integer brandId);

    List<Commission> selectAll(@Param("brandId") Integer brandId);

    //根据 套餐折扣率(套餐成交价÷套餐原价合计x100)和套餐成交价 获取 销售提成率
    Commission getCommissionAmount(@Param("discount") BigDecimal discount,
                                   @Param("orderAmount") BigDecimal orderAmount,
                                   @Param("brandId") Integer brandId);

    @Delete("delete from commission where brandId=#{brandId}")
    int clear(@Param("brandId") Integer brandId);

    //获取配置的最低折扣
    BigDecimal minDiscount(@Param("brandId") Integer brandId);
}
